﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Frontend/Frontend.Master"
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<IntroduceCompany.ProductListView>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Cart
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table border="0" cellpadding="0" cellspacing="0" width="100% ;">
        <tr>
            <td class="col-left bg_product">
                <!--Content column left here-->
            </td>
            <td class="col-center">
                <div class="cart">
                <h2><%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_header_Cart%></h2>

                <% using (Html.BeginForm("UpdateCart", "Order", FormMethod.Post))
                  {
                    if (ViewData["Cart"] != null)
                    { %>
                    <table class="cart_tb">
                        <tr>
                            <th>
                                <%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_lab_Image%>
                            </th>
                            <th>
                                <%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_lab_ProductID%>
                            </th>
                            <th>
                                <%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_lab_ProductName%>
                            </th>
                            <th>
                                <%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_lab_Quantity%>
                            </th>
                            <th>
                                <%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_lab_Price%> (VND)
                            </th>
                            <th>
                                <%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_lab_Amount%> (VND)
                            </th>
                            <th>
                                <%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_lab_Delete%>
                            </th>
                        </tr>
                        <%
                        double currencyExchangeRates_VN_USD = 0;
                        double totalMoney = 0;
                        foreach (var item in ViewData["Cart"] as List<IntroduceCompany.Models.ProductInCart>)
                        { %>
                        <tr>
                            <td class="txt_fc" style="width:80px;">
                                <img src="../../../Image/Product/thumbnail/<%=Html.Action("GetOneProductImage", "Product", new {productID= item.ProductID})%>"
                                    alt="<%= Html.Encode(item.ProductName)%>" class="img_pro" />
                            </td>
                            <td class="txt_fc" style="width:90px;">
                                <%= Html.Encode(item.ProductID)%>
                            </td>
                            <td>
                                <%= Html.Encode(item.ProductName)%>
                            </td>
                            <td class="txt_fc" style="width:60px;">
                                <input type="text" id="<%=item.ProductID %>" name="<%=item.ProductID %>" value="<%=item.Quantity%>" class="input_qua" maxlength="4"/>
                            </td>
                            <td class="txt_fr" style="width:80px;">
                                <p><%= Html.Encode(item.Price.ToString("N0", System.Globalization.CultureInfo.CreateSpecificCulture("vi-VN"))) %> VND</p>
                                <p>(<%= item.PriceUSD%> USD)</p>
                            </td>
                            <td class="txt_fr" style="width:110px;">
                                <p><%= Html.Encode(item.TotalMoney.ToString("N0", System.Globalization.CultureInfo.CreateSpecificCulture("vi-VN"))) %> VND</p>
                                <p>(<%= item.TotalMoney * item.CurrencyExchangeRates_VN_USD%> USD)</p>
                            </td>
                            <td class="txt_fc" style="width:40px;">
                                <a href="<%= Url.Action("DeleteOneProductInCart", "Order", new { productID = item.ProductID })%>"
                                    onclick="javascript: if (confirm('Bạn muốn xóa sản phẩm tên: <%= Html.Encode(item.ProductName)%> khỏi giỏ hàng?')) { window.location.href='#' } else { return false; };">
                                    <img src="../../../Content/Frontend/icons/icon-delete.png" alt=""/></a>
                            </td>
                        </tr>
                        <% totalMoney += (item.Price * item.Quantity);
                           currencyExchangeRates_VN_USD = item.CurrencyExchangeRates_VN_USD;
                          }%>
                          <tr>
                            <td class="txt_fr" colspan="5"><span class="black"><%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_lab_TotalMoney%></span></td><td class="txt_fr" colspan="2"><span class="red"><%=totalMoney.ToString("N0", System.Globalization.CultureInfo.CreateSpecificCulture("vi-VN"))%> VND</span><br /><span class="black"><%=totalMoney * currencyExchangeRates_VN_USD%> USD</span></td>
                          </tr>
                    </table>
                    <div class="fr">
                        <a class="button" href="<%= Url.Action("CreateOrder", "Order")%>">
                            <%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_btn_Order%></a>
                    </div>
                    <div class="fr" style="margin:0 20px;"><input type="submit" value="<%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_btn_Update%>" /></div>
                    <%  }
                    else
                    { %>
                        <p class="red txt_fc"><%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_lab_NoticeNoProductInCart%></p>
                        <br class="clear"/>
                    <%} 
                    } %>
                    <div class="fl"><a class="button" href="<%= Url.Action("CountinueBuyProduct", "Order")%>"><%= IntroduceCompany.Resources.Resx.Frontend_Order_Cart_link_ContinueBuyProduct%></a></div>
                </div>
            </td>
        </tr>
    </table>
</asp:Content>
